home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Libraries / SAT 2.3a1 / Collision ƒ / Collision.c < prev    next >
Encoding:
Text File  |  1994-11-04  |  1.5 KB  |  69 lines  |  [TEXT/KAHL]

  1.  
  2. //• C translation from Pascal source file: SATcollision.p
  3.  
  4. //• *****************************.
  5. //• ********* SAT Collision **********.
  6. //• *****************************.
  7.  
  8. //• A SAT demo that is slightly over SATminimal, demonstrating the simplest.
  9. //• collision handling based on the kind field (KindCollision)..
  10.  
  11. //• main SATcollision;
  12.  
  13. #include "SAT.h"
  14. #include "Collision.h"
  15. //, sMrEgghead, sApple;
  16.  
  17.  
  18. SpritePtr ignoreSp;
  19. long l;
  20. Point p;
  21.  
  22. main ()
  23. {
  24.     MaxApplZone ();
  25.     FlushEvents (everyEvent - diskMask, 0 );
  26. #ifdef THINK_C
  27.     InitGraf (&thePort);
  28. #else
  29.     InitGraf (&qd.thePort);
  30. #endif
  31.     InitFonts ();
  32.     InitWindows ();
  33.     InitMenus ();
  34.     TEInit ();
  35.     InitDialogs (nil);        /* no restart proc */
  36.     InitCursor ();
  37.  
  38.     MoreMasters ();
  39.     MoreMasters ();
  40.  
  41. //• Initialize SAT.
  42.     SATConfigure(true, kVPositionSort, kKindCollision, 32);
  43.     SATInit(128, 129, 512, 322);
  44.  
  45. //• Initialize sprite units.
  46.     InitMrEgghead ();
  47.     InitApple ();
  48.  
  49. //• Make sprites.
  50.     GetMouse(&p); //• We get the mouse position in order to put Mr Egghead under it immediately.
  51.     ignoreSp = SATNewSprite(0, p.h, p.v, &SetupMrEgghead);
  52.     ignoreSp = SATNewSprite(0, 0, Rand(gSAT.offSizeV - 32), &SetupApple);
  53.  
  54.     HideCursor();
  55.  
  56.     do
  57.         {
  58.         l = TickCount ();
  59.         SATRun(true); //• Run a frame of animation.
  60.         while ( l > TickCount () - 3 ) //• Speed limit.
  61.             ;
  62.  
  63. //• Start a new apple once in a while.
  64.         if ( Rand(40) == 1 )
  65.             ignoreSp = SATNewSprite(0, 0, Rand(gSAT.offSizeV - 32), &SetupApple);
  66.     } while (! Button ());
  67.     ShowCursor ();
  68.     SATSoundShutup (); //• Always make sure the sound channel is de-allocated!.
  69. }